﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace LiuLin.OQ2014.Extension
{
    public class Config
    {
        public static string GetConnectionString()
        {
            string filePath = System.Environment.CurrentDirectory + @"\Config.xml";
            string nodePath = "/Configuration/ConnectionString";
            string conn = string.Empty;
            try
            {
                conn = XMLHelper.GetXmlNodeByXpath(filePath, nodePath).InnerText;
            }
            catch (Exception ex)
            {
                LogHelper.Error("获取mongo连接字符串失败，请检查配置文件。");
                return conn;
            }
            return conn;
        }


        public static string GetDataBaseName()
        {
            string filePath = System.Environment.CurrentDirectory + @"\Config.xml";
            string nodePath = "/Configuration/DataBaseName";
            string conn = string.Empty;
            try
            {
                conn = XMLHelper.GetXmlNodeByXpath(filePath, nodePath).InnerText;
            }
            catch (Exception ex)
            {
                MessageBox.Show("获取数据库名失败，请检查配置文件。");
                return conn;
            }
            return conn;
        }
    }
}
